package com.chen10.cattle.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringTools {
    public static String getApi(String url) {
        // 定义一个正则表达式来匹配 /api 及其后的路径部分
        Pattern pattern = Pattern.compile("/api(/[^#?]*)?");
        Matcher matcher = pattern.matcher(url);

        if (matcher.find()) {
            // 获取匹配的内容
            return matcher.group();
        } else {
            return "The '/api' path was not found.";
        }
    }
}
